home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / demos / dosunixdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-02-08  |  2.5 KB  |  85 lines

  1. {
  2. GPC demo program for the DosUnix unit.
  3. Some routines to support writing programs portable between Dos and Unix.
  4.  
  5. Copyright (C) 1999-2001 Free Software Foundation, Inc.
  6.  
  7. Author: Frank Heckenbach <frank@pascal.gnu.de>
  8.  
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License as
  11. published by the Free Software Foundation, version 2.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program; see the file COPYING. If not, write to
  20. the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. Boston, MA 02111-1307, USA.
  22.  
  23. As a special exception, if you incorporate even large parts of the
  24. code of this demo program into another program with substantially
  25. different functionality, this does not cause the other program to
  26. be covered by the GNU General Public License. This exception does
  27. not however invalidate any other reasons why it might be covered
  28. by the GNU General Public License.
  29. }
  30.  
  31. program DosUnixDemo;
  32.  
  33. uses GPC, DosUnix;
  34.  
  35. const
  36.   ExtraCR = {$ifdef __OS_DOS__} '' {$else} #13 {$endif};
  37.   Command = 'foo &> bar';
  38.  
  39. var
  40.   t : Text;
  41.   s, n : TString;
  42.  
  43. begin
  44.   Writeln ('Demo of TranslateRedirections:');
  45.   Writeln;
  46.   Writeln ('A sample command line: `', Command, '''');
  47.   Writeln ('The command line with redirections translated: `',
  48.     TranslateRedirections (Command), '''');
  49.   Writeln ('(You should only see a difference under Dos.)');
  50.   Writeln;
  51.   Writeln;
  52.   Writeln ('Demo of AssignDos:');
  53.   Writeln;
  54.   Writeln ('Creating a file with extra CRs (if not under Dos).');
  55.   n := GetTempFileName;
  56.   Assign (t, n);
  57.   Rewrite (t);
  58.   Writeln (t, 'foo', ExtraCR);
  59.   Writeln (t, 'bar', ExtraCR);
  60.   Writeln (t, 'Hello world', ExtraCR);
  61.   Writeln ('Reading back the file in the normal way.');
  62.   Writeln ('The `.'' "after" each line will show the effect of the extra CR (not under Dos).');
  63.   Assign (t, n);
  64.   Reset (t);
  65.   while not EOF (t) do
  66.     begin
  67.       Readln (t, s);
  68.       Writeln (s, '.')
  69.     end;
  70.   Close(t);
  71.   Writeln;
  72.   Writeln ('Now reading the file using AssignDos.');
  73.   Writeln ('This should work correctly whether under Dos or not.');
  74.   AssignDos (t, n);
  75.   Reset (t);
  76.   while not EOF (t) do
  77.     begin
  78.       Readln (t, s);
  79.       Writeln (s, '.')
  80.     end;
  81.   Close (t);
  82.   Assign (t, n);
  83.   Erase (t)
  84. end.
  85.